//
//  XJWalletChargeBottomView.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/5/23.
//  Copyright © 2018年 Tzyang. All rights reserved.
//  应付:￥100.00         立即支付

#import "XJWalletChargeBottomView.h"
@interface XJWalletChargeBottomView()
@property(nonatomic, strong) UIView *bgView; // 习惯下面垫一层 <div>  xxxxx </div>
@property(nonatomic, strong) UILabel *yingFuLabel; // 应付:
@property(nonatomic, strong) UILabel *moneyLabel; // ￥100.00
@property(nonatomic, strong) UIButton *payNowButton; // 立即支付
@end

@implementation XJWalletChargeBottomView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/




#pragma mark - 一 初始化
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupView];
    }
    return self;
}
- (void)setupView {
    [self addSubview:self.bgView];
    
    [self.bgView addSubview:self.yingFuLabel];
    [self.bgView addSubview:self.moneyLabel];
    [self.bgView addSubview:self.payNowButton];
}

#pragma mark - 一 lazy
- (UIView *)bgView {
    if(!_bgView) {
        _bgView = [[UIView alloc] init];
        _bgView.backgroundColor = [UIColor whiteColor];
    }
    return _bgView;
}
- (UILabel *)yingFuLabel {
    if(!_yingFuLabel){
        _yingFuLabel = [[UILabel alloc] init];
        _yingFuLabel.text = @"应付：";
        _yingFuLabel.font = XJFONTSET_R(14.0);
    }
    return _yingFuLabel;
}
- (UILabel *)moneyLabel {
    if(!_moneyLabel){
        _moneyLabel = [[UILabel alloc] init];
        _moneyLabel.textColor = [UIColor redColor];
        _moneyLabel.font = XJFONTSET_M(15.0);
    }
    return _moneyLabel;
}

- (UIButton *)payNowButton {
    if(!_payNowButton) {
        _payNowButton = [UIButton buttonWithType:(UIButtonTypeCustom)];
        [_payNowButton setTitle:@"立即支付" forState:(UIControlStateNormal)];
        [_payNowButton setTitleColor:[UIColor blackColor] forState:(UIControlStateNormal)];
        [_payNowButton setTitleColor:[UIColor lightGrayColor] forState:(UIControlStateNormal)];
        
        _payNowButton.layer.masksToBounds = YES;
        _payNowButton.layer.cornerRadius = 10;
        
        [_payNowButton addTarget:self action:@selector(payNowButtonAction) forControlEvents:(UIControlEventTouchUpInside)];
    }
    return _payNowButton;
}

#pragma mark - 三 layout
- (void)layoutSubviews {
    [super layoutSubviews];
    
    [self.bgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
    
    [self.yingFuLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.bgView.mas_left).offset(15);
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(50, 30));
    }];
    
    [self.moneyLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.yingFuLabel.mas_right);
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(150, 40));
    }];
    
    [self.payNowButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.bgView.mas_right).offset(-15);
        make.centerY.equalTo(self.bgView.mas_centerY);
        make.size.mas_equalTo(CGSizeMake(100, 100));
    }];
}

#pragma mark - 四 点击事件
- (void)payNowButtonAction {
    XJLog(@"点击立即支付按钮");
}
@end
